package com.ruoyi.system.mapper;

import com.ruoyi.system.api.domain.Attachment;
import com.ruoyi.system.api.domain.AttachmentAssociated;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 附件关联Mapper接口
 * 
 * @author ruoyi
 * @date 2024-09-18
 */
public interface AttachmentAssociatedMapper 
{
    /**
     * 查询附件关联
     * 
     * @param id 附件关联主键
     * @return 附件关联
     */
    public AttachmentAssociated selectAttachmentAssociatedById(Long id);

    /**
     * 查询附件关联列表
     * 
     * @param attachmentAssociated 附件关联
     * @return 附件关联集合
     */
    public List<AttachmentAssociated> selectAttachmentAssociatedList(AttachmentAssociated attachmentAssociated);

    /**
     * 新增附件关联
     * 
     * @param attachmentAssociated 附件关联
     * @return 结果
     */
    public int insertAttachmentAssociated(AttachmentAssociated attachmentAssociated);

    /**
     * 修改附件关联
     * 
     * @param attachmentAssociated 附件关联
     * @return 结果
     */
    public int updateAttachmentAssociated(AttachmentAssociated attachmentAssociated);

    /**
     * 删除附件关联
     * 
     * @param id 附件关联主键
     * @return 结果
     */
    public int deleteAttachmentAssociatedById(Long id);

    /**
     * 批量删除附件关联
     * 
     * @param ids 需要删除的数据主键集合
     * @return 结果
     */
    public int deleteAttachmentAssociatedByIds(Long[] ids);

    @Select("select file_id,name from  attachment att inner join attachment_associated aa on att.id=aa.attachment_id where aa.associated_id = #{associatedId}")
    List<Attachment> getFileIdByAssociatedId(Long associatedId);
}
